<template>
  <div id="valuemain" style="height:100%">
    <!-- <div id="squarecontainer" style="height: 550px; width: 550px; float: left; margin: 20px; margin-top: 50px; margin-left: 100px"></div> -->
    <h2>欢迎来到新零售平台</h2>
  </div>
</template>

<script>
import echarts from '@/views/platform/value/echarts.min.js'
import axios from 'axios'
import request from '@/utils/request'
export default {
  name: 'valueMain',
  data() {
    return {
      userId: '',
      userName: '',
      squareChart: null,
      squareapp: {},
      squareoption: {
        title: {
            text: '价值优化',
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#283b56'
                }
            }
        },
        legend: {
        //   data:['每单价值优化']
        },
        toolbox: {
          show: true,
          feature: {
            dataView: {readOnly: false},
            restore: {},
            saveAsImage: {}
          }
        },
        dataZoom: {
          show: false,
          start: 0,
          end: 100
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: true,
            data: [],
            name: '单数'
          }
        ],
        yAxis: [
          {
            type: 'value',
            scale: true,
            name: '每单节省金额 ',
            max: 100,
            min: 0,
            boundaryGap: [0.2, 0.2]
          }
        ],
        series: [
          {
            name: '每单节省金额',
            type: 'bar',
            xAxisIndex: 0,
            yAxisIndex: 0,
            data: []
          }
        ]
      }
    }
  },
  mounted() {
    this.vueinit()
  },
  methods: {
    setSquareChartData() {
      //  squareChart  柱状图
      var squaredom = document.getElementById("squarecontainer");
      this.squareChart = echarts.init(squaredom);

      //  get data
      var x_data = [1,2,3,4,5,6]
      var y_value = [10,30,50,40,32,35]

      //  set data
      this.squareoption.xAxis[0].data = x_data
      this.squareoption.series[0].data = y_value

      if (this.squareoption && typeof this.squareoption === "object") {
        this.squareChart.setOption(this.squareoption, true);
      }
    },
    vueinit() {
      this.userId = JSON.parse(sessionStorage.getItem('user')).userId
      this.userName = JSON.parse(sessionStorage.getItem('user')).userName

      // this.setSquareChartData()

    }
  }
}
</script>

<style scoped>

</style>
